<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>专业化评价预警工具 - 登录</title>
    <style>
        /* 保留原有的样式 */
        .container {
            background-color: white;
            padding: 2rem;
            border-radius: 8px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 400px;
            position: relative;
            overflow: hidden;
        }
        .container::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background-color: #2a9d8f;
        }
        .container::after {
            content: '';
            position: absolute;
            top: -50px;
            right: -50px;
            width: 100px;
            height: 100px;
            background-color: rgba(42, 157, 143, 0.1);
            border-radius: 50%;
        }
        h1 {
            color: #333;
            margin-bottom: 1.5rem;
            font-size: 1.75rem;
            text-align: center;
        }
        .input-group {
            margin-bottom: 1.25rem;
            position: relative;
        }
        label {
            display: block;
            margin-bottom: 0.5rem;
            color: #555;
            font-size: 0.9rem;
        }
        input[type="text"],
        input[type="password"],
        input[type="email"] {
            width: 100%;
            padding: 0.75rem;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 1rem;
            transition: border-color 0.3s, box-shadow 0.3s;
        }
        input[type="text"]:focus,
        input[type="password"]:focus,
        input[type="email"]:focus {
            outline: none;
            border-color: #2a9d8f;
            box-shadow: 0 0 0 3px rgba(42, 157, 143, 0.2);
        }
        .form-switch {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
            font-size: 0.9rem;
        }
        .form-switch a {
            color: #2a9d8f;
            text-decoration: none;
            transition: color 0.3s;
        }
        .form-switch a:hover {
            color: #238b7e;
            text-decoration: underline;
        }
        .submit-button {
            width: 100%;
            padding: 0.75rem;
            background-color: #2a9d8f;
            color: white;
            border: none;
            border-radius: 4px;
            font-size: 1rem;
            cursor: pointer;
            transition: background-color 0.3s, transform 0.1s;
        }
        .submit-button:hover {
            background-color: #238b7e;
        }
        .submit-button:active {
            transform: translateY(1px);
        }
        .system-info {
            margin-top: 2rem;
            padding-top: 1rem;
            border-top: 1px solid #eee;
            text-align: center;
            color: #777;
            font-size: 0.875rem;
        }
        @media (max-width: 480px) {
            .container {
                padding: 1.5rem;
            }
            h1 {
                font-size: 1.5rem;
            }
        }
        .hidden {
            display: none;
        }
        .delete-button {
            background-color: #e63946;
        }
        .delete-button:hover {
            background-color: #d62828;
        }
    </style>
</head>
<body>
<div id="login_div" style="position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);width: 400px">
    <div class="container">
        <div id="loginForm">
            <h1>专业化评价预警工具 - 登录</h1>
            <form @submit.prevent="submit">
                <div class="input-group">
                    <label for="loginUsername">用户名</label>
                    <input type="text" id="loginUsername" name="username" placeholder="请输入用户名" required>
                </div>
                <div class="input-group">
                    <label for="loginPassword">密码</label>
                    <input type="password" id="loginPassword" name="password" placeholder="请输入密码" required>
                </div>
                <button type="submit" class="submit-button">登录</button>
            </form>
        </div>
                <div class="system-info">
                    专业化评价预警工具
                </div>
    </div>
</div>
<script src="${ROOT}/mind/js/vue2.js"></script>
<link href="${ROOT}/mind/css/element-ui.css" rel="stylesheet">
<!-- 引入Element Plus的JavaScript -->
<script src="${ROOT}/mind/js/element-ui.js"></script>
<script>
    new Vue({
        el: '#login_div',
        methods:{
            submit(){
                    const username = document.getElementById('loginUsername').value;
                    const password = document.getElementById('loginPassword').value;

                    let url='http://127.0.0.1:8001/login?u='+username+'&p='+password
                    fetch(url)
                        .then(response => response.json())
                        .then(data => {
                            if (data.data) {
                                window.postMessage( data.data, '*');
                                sessionStorage.setItem('isLoggedIn','true')
                                sessionStorage.setItem('userName',username)
                                sessionStorage.setItem('password',password)
                                sessionStorage.setItem('userPermissions',data.data)
                                window.location.href = '${ROOT}/';

                                // window.location.reload();
                            } else {
                                this.$message({
                                    message: '登录失败，请检查用户名和密码',
                                    type: 'error'
                                });
                            }
                        })
                        .catch(error => {
                            this.$message({
                                message: '登录请求出错，请稍后再试',
                                type: 'error'
                            });
                        });
            }
        }
    })
</script>
</body>
</html>